package cn.edu.nuc.jframe;

import java.awt.EventQueue;

import javax.swing.JFrame;
import java.awt.Toolkit;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JPasswordField;
import javax.swing.JTextArea;

public class Jframe1 {

	private JFrame frame;
	private JTextField name;
	private JPasswordField userpassword;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					Jframe1 window = new Jframe1();
					window.frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public Jframe1() {
		initialize();
	}

	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frame = new JFrame();
		frame.setIconImage(Toolkit.getDefaultToolkit().getImage(Jframe1.class.getResource("/recourse/image/1.jpg")));
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		name = new JTextField();
		name.setBounds(100, 41, 200, 21);
		frame.getContentPane().add(name);
		name.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("用户名");
		lblNewLabel.setBounds(36, 44, 54, 15);
		frame.getContentPane().add(lblNewLabel);
		
		JLabel lblNewLabel_1 = new JLabel("密  码");
		lblNewLabel_1.setBounds(36, 98, 54, 15);
		frame.getContentPane().add(lblNewLabel_1);
		
		JButton username = new JButton("登录");
		username.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				 String username=name.getText();
			     String password=userpassword.getText();
			     if(username.equals("张三")&&"123456".equals(password)){
			    	JOptionPane.showMessageDialog(frame, "登录成功");
			     }else{
			    	 System.out.println("登录失败");
			    	 JOptionPane.showMessageDialog(frame, "登录失败");
			     }
				 
				
				
			}
		});
		username.setBounds(54, 150, 93, 23);
		frame.getContentPane().add(username);
		
		JButton btnNewButton_1 = new JButton("重置");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				name.setText("");
				userpassword.setText("");
			}
		});
		btnNewButton_1.setBounds(219, 150, 93, 23);
		frame.getContentPane().add(btnNewButton_1);
		
		userpassword = new JPasswordField();
		userpassword.setBounds(100, 95, 200, 21);
		frame.getContentPane().add(userpassword);
	}
}
